package types

import (
	"context"
	"io"

	"xemo.top/docker/cli/cli/config/types"
)

const (
	// CommunityEngineImage 社区仓库名
	// CommunityEngineImage is the repo name for the community engine
	CommunityEngineImage = "engine-community"

	// EnterpriseEngineImage 企业仓库镜像名
	// EnterpriseEngineImage is the repo name for the enterprise engine
	EnterpriseEngineImage = "engine-enterprise"

	// RegistryPrefix is the default prefix used to pull engine images
	RegistryPrefix = "docker.io/store/docker"

	// ReleaseNotePrefix is where to point users to for release notes
	ReleaseNotePrefix = "https://docs.docker.com/releasenotes"

	// RuntimeMetadataName 是运行时元数据文件的名称
	// RuntimeMetadataName is the name of the runtime metadata file
	// 当作为标签存储在容器上时，其前缀为 “com.docker.”。
	// When stored as a label on the container it is prefixed by "com.docker."
	RuntimeMetadataName = "distribution_based_engine"
)

// ContainerizedClient 可用于管理作为containerd上的容器运行的Docker的生命周期。
// ContainerizedClient can be used to manage the lifecycle of dockerd running as a container on containerd.
type ContainerizedClient interface {
	Close() error
	ActivateEngine(ctx context.Context, opts EngineInitOptions, out OutStream, authConfig *types.AuthConfig) error
	DoUpdate(ctx context.Context, opts EngineInitOptions, out OutStream, authConfig *types.AuthConfig) error
}

// OutStream 是用于编写正常程序输出的输出流。
// OutStream is an output stream used to write normal program output.
type OutStream interface {
	io.Writer
	FD() uintptr
	IsTerminal() bool
}

// EngineInitOptions 包含在初始化容器化docker引擎期间使用的配置设置
// EngineInitOptions contains the configuration settings use during initialization of a containerized docker engine
type EngineInitOptions struct {
	RegistryPrefix     string
	EngineImage        string
	EngineVersion      string
	ConfigFile         string
	RuntimeMetadataDir string
}

// RuntimeMetadata 保存有关守护进程的平台信息
// RuntimeMetadata holds platform information about the daemon
type RuntimeMetadata struct {
	Platform             string `json:"platform"`
	ContainerdMinVersion string `json:"containerd_min_version"`
	Runtime              string `json:"runtime"`
	EngineImage          string `json:"engine_image"`
}
